#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <iostream>
#define max2(a, b) ((a) > (b) ? (a) : (b))
#define min2(a, b) ((a) < (b) ? (a) : (b))

using namespace std;

const int INF = 10000000;
int main()
{
    int dp[15][105][105];
    for (int i = 1; i <= 100; i++)
        for (int j = i; j <= 100; j++)
            dp[1][i][j] = (j - i + 1) * (i + j) / 2;

    for (int k = 2; k <= 10; k++)
        for (int j = 100; j >= 1; j--)
            for (int i = j; i >= 1; i--)
            {
                dp[k][i][j] = INF;
                for (int t = i; t <= j; t++)
                    dp[k][i][j] = min(dp[k][i][j], t + max(dp[k - 1][i][t - 1], dp[k][t + 1][j]));
            }
    int k, m, t;
    scanf("%d", &t);
    while (t--)
    {
        scanf("%d%d", &k, &m);
        printf("%d\n", dp[k][1][m]);
    }
    return 0;
}